import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart';
import 'package:noway/Hitokoto.dart';
class GetInfo {
  /**
   * datas
   */
  Future<Hitokoto> getDataFromNet(url) async {
    return get(url)
        .asStream()
        .map((resp)=>resp.body)
        .map((str)=>json.decode(str))
        .map((hashMap){
          Hitokoto hitokoto = new Hitokoto();
          hitokoto.id = hashMap['id'];
          hitokoto.fromWhere = hashMap['fromWhere'];
          hitokoto.creator = hashMap['creator'];
          hitokoto.createdAt = hashMap['createdAt'];
          hitokoto.koto = hashMap['koto'];
          return hitokoto;
        })
        .first;
  }
}